<!doctype html>
<html class="no-js">

  <head>
    <meta charset="utf-8">
    <title>修改密码</title>

    <#include "/head-file.htm" />

  </head>


  <body style="background-color:#f3f5f7;">
    <div class="ms-password-change" id="vue-ms-password-change">
      <!--头部导航条-->
      <#include "/head.htm" />

      <!--添加收获地址列表-->
      <form class="am-form ms-form">
        <div class="am-form-group">
          <label for="doc-ipt-email-1" class="ms-text">请填写旧密码</label>
          <input type="password" v-model="peopleOldPassword" v-on:input="active" name="peopleOldPassword" class="ms-text" id="doc-ipt-email-1" placeholder="请填写旧密码">
        </div>
        <div class="am-form-group">
          <label for="doc-ipt-pwd-1" class="ms-text">请填写新密码</label>
          <input type="password" v-model="peoplePassword" v-on:input="active"  name="peoplePassword" class="ms-text" id="doc-ipt-pwd-1" placeholder="6-20位，不能与旧密码相同">
        </div>
          <v-touch type="button" v-on:tap="changePassword" v-bind:class="{'am-disabled':isActive}" class="am-btn am-btn-danger am-radius  am-btn-block" id='ms-password'>确认</v-touch>
      </form>
      <div>
      <script type="text/javascript">
      ms.load(["ms","ms.people"],function(ms,mpeople){
        var vu = new Vue({
          el: '#vue-ms-password-change',
          data:{
            title:'修改密码',
            backBtn:"javascript:history.back()",
            isActive:true,
            peopleOldPassword:"",
            peoplePassword:"",
          },
          methods: {
            active: function(){
              //判断用户名、密码、验证码都输入后才启动登录按钮
              if (!validator.isNull(this.peopleOldPassword) && !validator.isNull(this.peoplePassword)){
                this.isActive = false;
              }else{
                this.isActive = true;
              }
            },
            changePassword: function(event){

              if(!validator.isLength(this.peopleOldPassword,{min:6,max:20})){
                alert("旧密码为6-20个字符");
                return;
              }
              if(!validator.isLength(this.peoplePassword,{min:6,max:20})){
                alert("新密码为6-20个字符");
                return;
              }
              if(this.peoplePassword.indexOf(" ") >=0){
                alert("新密码不能包含空格");
                return;
              }
              if(this.peopleOldPassword == this.peoplePassword){
                alert("新密码不能与旧密码相同");
              }else{
                mpeople.people.changePassword($("form").serialize(),function(returnJson){
                    if(returnJson.result){
                      alert("密码修改成功，请重新登录")
                      $.ajax({
			                    type: "POST",
			                    url: "{ms:global.host/}/people/quit.do",
			                    success: function(msg) {
			                    }
			                })
                      location.href="{ms:global.host/}/login.do";
                    }else{
                      alert("旧密码错误");
                    };
                })
              }
            
            }
          }
        });
      });
      </script>

        <!--[if (gte IE 9)|!(IE)]><!-->
        
        <!--<![endif]-->
        <!--[if lte IE 8 ]>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->
        <script src="http://cdn.mingsoft.net/plugins/AmazeUI/2.7.2/js/amazeui.min.js"></script>
  </body>

</html>